<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pr="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/WEB-INF/facelets/admintemplate.xhtml">
        <ui:define name="admincontent">
            <ui:param name="title" value="Admin"/>
            
            <h1>This is addproduct.xhtml</h1>
            
            

            <h:form id="form" enctype="multipart/form-data">
                
                
                <h:panelGrid id="editproduct" columns="3">
                    

                    <h:outputText value="Product Name: " /> 
                    <pr:inputText id="productname" value="#{productBacking.product.name}">
                        <f:validateLength minimum="3"/>
                    </pr:inputText>
                    <pr:message for="productname"/>



                    <h:outputText value="Manufacturer: " /> 
                    <pr:inputText id="manufacturer" value="#{productBacking.product.manufacturer}">
                        <f:validateLength minimum="3"/>
                    </pr:inputText>
                    <pr:message for="manufacturer"/>


                     

                    <h:outputText value="Product Category: " /> 
                    <pr:selectOneMenu id="selectcategory" value="#{productBacking.categoryName}" >
                        <f:selectItem itemLabel="Select One" itemValue=""/>
                      <f:selectItems value="#{productBacking.categories}" var="cat"
                                       itemLabel="#{cat.name}" itemValue="#{cat}"/>
                    </pr:selectOneMenu>
                    <pr:message for="selectcategory"/>
                    

                    <h:outputText value="Product Price: " /> 
                    <pr:inputText id="productprice" value="#{productBacking.product.price}">
                        <f:validateDoubleRange minimum="0.1" maximum="99999"/>
                    </pr:inputText>
                    <pr:message for="productprice"/>

                    <h:outputText value="Weight: " /> 
                    <pr:inputText id="productweight" value="#{productBacking.product.weight}">
                        <f:validateDoubleRange minimum="0.0" maximum="99999"/>
                    </pr:inputText>
                    <pr:message for="productweight"/>


                    <h:outputText value="Discription: " /> 
                    <pr:inputTextarea id="discription" autoResize="yes" maxHeight="100" effectDuration="400" 
                                      value="#{productBacking.product.description}" style="height:200px;width:250px;font-size: smaller"/>
                    <pr:message for="discription"/>
                    
                    <h:outputText value="On Sale: " /> 
                    <h:selectBooleanCheckbox id="onsale" title="On Sale" value="#{productBacking.product.onSale}" />
                    <pr:message for="onsale"/>




                    <h:outputText value="Discount: " /> 
                    <pr:inputText id="discount" value="#{productBacking.product.discount}">
                        <f:validateDoubleRange minimum="0.0" maximum="1"/>
                    </pr:inputText>
                    <pr:message for="discount"/>



                    <h:outputText value="Attribute 1:  " /> 
                    <pr:inputText id="productattrib1" value="#{productBacking.product.attr1}">
                    </pr:inputText>
                    <pr:message for="productattrib1"/>

                    <h:outputText value="Attribute 2: " /> 
                    <pr:inputText id="productattrib2" value="#{productBacking.product.attr2}">
                    </pr:inputText>
                    <pr:message for="productattrib2"/>

                    <h:outputText value="Image: " /> 

                    <pr:fileUpload id="fileupload" mode="simple" fileUploadListener="#{fileUploadController.handleFileUpload}" allowTypes="*.jpg;*.png;*.gif;"/> 
                    <pr:message for="fileupload"/>
                    
                    
                                        <h:outputText value="Grouped with: " /> 
                    <pr:selectManyMenu id="groupedwith" value="#{productBacking.product.groupedWith}"  
                                       style="height:200px;width:300px;font-size: smaller">  
                        <f:selectItems value="#{productListingBacking.products}"  
                                       var="product" itemLabel="#{product.name} - #{product.attr1}"  
                                       itemValue="#{product}"/>  
                    </pr:selectManyMenu>  
                     <pr:message for="groupedwith"/>

                    <h:outputText value="Removed: " />  
                    <h:selectBooleanCheckbox id="removed" title="Removed" value="#{productBacking.product.removed}" /> 
                    <pr:message for="removed"/>
                    
                                        <h:outputText value="Visible: " />  
                    <h:selectBooleanCheckbox id="visible" title="Visible" value="#{productBacking.product.visible}" /> 
                    <pr:message for="visible"/>
                    <br/>




                </h:panelGrid>

                <pr:commandButton value="Save Changes" action="#{productBacking.saveProduct()}" ajax="false"/>
                <br/>

                <br/>

            </h:form>



        </ui:define>
    </ui:composition>
</html>

